package com.wxq.day0415.formater;

import org.springframework.format.Formatter;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @Author wxq
 * @Date 2021/4/15
 **/
@Component
public class DateFormater implements Formatter<Date> {


    public static void main(String[] args) {
        System.out.println(1);
    }

    private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    @Override
    public Date parse(String text, Locale locale) throws ParseException {
        dateFormat.format((dateFormat.parse(text)));
        return dateFormat.parse(text);

    }

    @Override
    public String print(Date date, Locale locale) {
        return dateFormat.format(date);
    }
}
